//
//  PersonalSettingsViewController.m
//  NordsonTesco
//
//  Created by mac on 16/6/24.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "PersonalSettingsViewController.h"
#import "HeaderCell.h"
#import "ViewAllOrdersViewController.h"

@interface PersonalSettingsViewController ()
{
    UIView *navigationPersonView;
}
@property(nonatomic,strong)HeaderCell *personHeaderCell;
@end

@implementation PersonalSettingsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self personCollectionViewInitAction];
    [self userSettingAction];
    // Do any additional setup after loading the view.
}

-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    navigationPersonView.hidden = NO;
    //    self.navigationController.navigationBarHidden = YES;
        self.tabBarController.tabBar.hidden = NO;
}

- (void)userSettingAction{
    
    navigationPersonView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScrernWidth, 195)];
    navigationPersonView.backgroundColor = [UIColor colorWithRed:246/255.0 green:59/255.0 blue:21/255.0 alpha:1];;
    [self.navigationController.view addSubview:navigationPersonView];
    
    //设置
    UIImageView *userSettingImage = [[UIImageView alloc]initWithFrame:CGRectMake(navigationPersonView.bounds.size.width-55, 27, 18, 18)];
    userSettingImage.image = [UIImage imageNamed:@"she"];
    [navigationPersonView addSubview:userSettingImage];
    UILabel *userSettingLabel = [[UILabel alloc]initWithFrame:CGRectMake(navigationPersonView.bounds.size.width-35, 27, 30, 20)];
    userSettingLabel.text = @"设置";
    userSettingLabel.font =[UIFont systemFontOfSize:13];
    userSettingLabel.textColor = [UIColor whiteColor];
    [navigationPersonView addSubview:userSettingLabel];
    
    UIButton *userSettingButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [userSettingButton addTarget:self action:@selector(userSettingeButtonAction) forControlEvents:UIControlEventTouchUpInside];
    userSettingButton.frame = CGRectMake(navigationPersonView.bounds.size.width - 55,27, 55, 20);
    [navigationPersonView addSubview:userSettingButton];
    
    
    
    //头像
    UIButton *userHeadButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [userHeadButton addTarget:self action:@selector(userHeadButtonAction) forControlEvents:UIControlEventTouchUpInside];
    CGSize userHeadButtonSize = CGSizeMake(50, 50);
    userHeadButton.frame = CGRectMake(navigationPersonView.center.x-25,60, userHeadButtonSize.width, userHeadButtonSize.height);
        [userHeadButton setImage:[UIImage imageNamed:@"tu"] forState:UIControlStateNormal];
    [navigationPersonView addSubview:userHeadButton];
    
    //点击登陆
    UIButton *userSignInButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [userSignInButton addTarget:self action:@selector(userSignInButtonAction) forControlEvents:UIControlEventTouchUpInside];
    userSignInButton.frame = CGRectMake(navigationPersonView.center.x-30,120,60, 20);
    userSignInButton.titleLabel.font = [UIFont systemFontOfSize: 12];
    [userSignInButton setTitle:@"请点击登录" forState:UIControlStateNormal];
    [navigationPersonView addSubview:userSignInButton];
    
    //普通会员
    UIView *memberView = [[UIView alloc]initWithFrame:CGRectMake(kScrernWidth-70, 100, 100, 30)];
    memberView.alpha = 0.3;
    memberView.layer.masksToBounds = YES;
    memberView.layer.cornerRadius = 15;
    memberView.backgroundColor = [UIColor grayColor];
    [navigationPersonView addSubview:memberView];
    
    UILabel *memberLabel = [[UILabel alloc]initWithFrame:CGRectMake(kScrernWidth-80, 99, 100, 30)];
    memberLabel.text = @"普通会员";
    memberLabel.textColor = [UIColor whiteColor];
    memberLabel.font = [UIFont systemFontOfSize:13];
    memberLabel.textAlignment = NSTextAlignmentCenter;
    [navigationPersonView addSubview:memberLabel];
    
    NSArray *loop_array = @[@"优惠卷",@"收藏",@"余额"];
    NSInteger loopTag = 400;
    for (int i = 0 ; i < 3; i++) {
        UILabel *loopLabel = [[UILabel alloc]initWithFrame:CGRectMake(1+(kScrernWidth/3)*i,150,(kScrernWidth/3)-2, 45)];
        loopLabel.text = [loop_array objectAtIndex:i];
        loopLabel.textAlignment = NSTextAlignmentCenter;
        loopLabel.textColor = [UIColor whiteColor];
        loopLabel.font = [UIFont systemFontOfSize:15];
        [navigationPersonView addSubview:loopLabel];
        
        UIButton *loopButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [loopButton addTarget:self action:@selector(loopButtonAction:) forControlEvents:UIControlEventTouchUpInside];
        loopButton.frame = CGRectMake(1+(kScrernWidth/3)*i,150,(kScrernWidth/3)-2, 45);
        loopButton.alpha = 0.2;
        loopButton.tag = loopTag++;
        loopButton.titleLabel.font = [UIFont systemFontOfSize: 15];
        [loopButton setTitle:[loop_array objectAtIndex:i] forState:UIControlStateNormal];
        loopButton.backgroundColor = [UIColor grayColor];
        [navigationPersonView addSubview:loopButton];
    }
}
- (void)loopButtonAction:(UIButton *)sender{
    switch (sender.tag) {
        case 400:{
            NSLog(@"优惠卷");
        }
            break;
        case 401:{
            NSLog(@"收藏");
        }
            break;
        case 402:{
            NSLog(@"余额");
        }
            break;
        default:
            break;
    }
}

- (void)userHeadButtonAction{
    NSLog(@"头像");
}
- (void)userSettingeButtonAction{
    NSLog(@"设置");
}
- (void)userSignInButtonAction{
    NSLog(@"点击登录");
}

#pragma mark -- collectionView
- (void)personCollectionViewInitAction{
    self.personCollectionView.delegate = self;
    self.personCollectionView.dataSource = self;
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 0;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    UICollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier : @"header" forIndexPath :indexPath];
    return cell;
}

//跳转
//- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
//{
//    NSLog(@"indexPath.row:  %ld",(long)indexPath.row);
////    CommodityModel *model = [guessArray objectAtIndex:indexPath.row];
////    [self performSegueWithIdentifier:@"commodityDetailInfo" sender:model];
//}

//headercell
- (UICollectionReusableView *) collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
    UICollectionReusableView *reusableView = nil;
    if (kind == UICollectionElementKindSectionHeader) {
        _personHeaderCell = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"header" forIndexPath:indexPath];
        reusableView = _personHeaderCell;
    }
    return reusableView;
}

#pragma mark -- 账户信息
- (IBAction)myAccountInformation:(UIButton *)sender {
    switch (sender.tag) {
        case 200:{
            NSLog(@"账户余额");
        }
            break;
        case 201:{
            NSLog(@"线下消费总额");
        }
            break;
        case 202:{
            NSLog(@"益购币");
        }
            break;
        case 203:{
            NSLog(@"赠送权重");
        }
            break;
        case 204:{
            NSLog(@"益购币赠送纪录");
        }
            break;
        case 205:{
            NSLog(@"提现");
        }
            break;
        case 206:{
            NSLog(@"充值");
        }
            break;
        case 207:{
            NSLog(@"银行卡");
        }
            break;
        default:
            break;
    }
}
#pragma mark -- 交易管理
- (IBAction)transactionManagement:(UIButton *)sender {
    switch (sender.tag) {
        case 220:{
            NSLog(@"线下订单");
        }
            break;
        case 221:{
            NSLog(@"益购币兑换");
        }
            break;
        case 222:{
            NSLog(@"线上订单");
        }
            break;
        default:
            break;
    }
}
#pragma mark -- 我的订单
- (IBAction)myOrder:(UIButton *)sender {
    switch (sender.tag) {
        case 230:{
            NSLog(@"待付款");
        }
            break;
        case 231:{
            NSLog(@"待发货");
        }
            break;
        case 232:{
            NSLog(@"待收货");
        }
            break;
        case 233:{
            NSLog(@"待完成");
        }
            break;
        default:
            break;
    }
}

#pragma mark -- 查看全部订单
- (IBAction)ViewallordersViewallordersviewAllOrders:(UIButton *)sender {
    NSLog(@"查看全部订单");
    ViewAllOrdersViewController *order = [[ViewAllOrdersViewController alloc]init];
    navigationPersonView.hidden = YES;
    self.tabBarController.tabBar.hidden = YES;
    [self.navigationController pushViewController:order animated:YES];
}
#pragma mark-- 个人资料
- (IBAction)personalData:(UIButton *)sender {
    NSLog(@"个人资料");
}
- (IBAction)accountSecurity:(UIButton *)sender {
    NSLog(@"账户安全");
}
//商家入口
- (IBAction)merchantEntrance:(UIButton *)sender {
    NSLog(@"商家入口");
}
//退出
- (IBAction)exitAccount:(UIButton *)sender {
    NSLog(@"退出");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
